hook.Add("EntityTakeDamage", "tdmdamagdfracrain", function(ent, dmginfo)
	if IsTDMCar(ent) and ent:GetDriver() and math.random(0,5)==0 then
		local defensemod = ent:GetDriver():GetTable().Playerstats.defense
		local mod = 1000*math.random(1,15/defensemod)
		print(dmginfo:GetDamage()*mod)
		dmginfo:ScaleDamage(mod)
		ent:GetDriver():TakeDamageInfo(dmginfo)
	end
end)


function IsTDMCar(vcl)
	if not IsValid(vcl) then return false end
	if not vcl:IsVehicle() then return false end
	if not vcl.VehicleTable then return false end

	//PrintTable( vcl:GetKeyValues())
	//print(  table.LowerKeyNames( vcl:GetKeyValues() ).vehiclescript )
	if string.find( string.lower(table.LowerKeyNames( vcl:GetKeyValues() ).vehiclescript), "tdmcars") then return true 
	else return false end
end